<%--
  Created by IntelliJ IDEA.
  User: Administrator
  Date: 2017/11/29 0029
  Time: 上午 9:55
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title>个人信息设置</title>
    <link rel="stylesheet" href="/static/plugins/layui/css/layui.css">
    <link rel="stylesheet" href="/static/css/common.css">
    <style>
        .container{
            margin-top: 20px;
        }
    </style>
</head>
<body>


<div class="wrap-padding-15">
    <span class="layui-breadcrumb">
          <a href="/" target="_top">首页</a>
          <a href="/vote">个人信息设置</a>
     </span>

    <div class="layui-tab layui-tab-card" lay-filter="vote_tab">
        <ul class="layui-tab-title">
            <li lay-id="1" class="layui-this">用户资料</li>
            <li lay-id="2">密码信息</li>
        </ul>
        <div class="layui-tab-content" >
            <div class="layui-tab-item layui-show container">
                <form  method="post" class="layui-form" id="updateMsgForm">
                    <input type="hidden" name="uid" id="uid value="${user.uid}">

                    <div class="layui-form-item">
                        <label class="layui-form-label">账号：</label>
                        <div class="layui-input-block">
                            <input type="text" name="username"  value="${user.username}" class="layui-input" lay-verify="required">
                        </div>
                    </div>
                    <div class="layui-form-item">
                        <label class="layui-form-label">工号：</label>
                        <div class="layui-input-block">
                            <input type="text" name="personid"  value="${user.personid}" class="layui-input" lay-verify="required">
                        </div>
                    </div>

                    <div class="layui-form-item">
                        <label class="layui-form-label">姓名：</label>
                        <div class="layui-input-block">
                            <input type="text" name="realname"  value="${user.realname}" class="layui-input" lay-verify="required">
                        </div>
                    </div>
                    <div class="layui-form-item">
                        <div class="layui-input-block">
                            <button class="layui-btn" lay-submit lay-filter="formSubmit1">保存</button>
                        </div>
                    </div>
                </form>
            </div>

            <div class="layui-tab-item container">
                <form class="layui-form" class="layui-form" id="rsetPwdForm">
                    <div class="layui-form-item">
                        <label class="layui-form-label">原密码：</label>
                        <div class="layui-input-block">
                            <input type="password" name="pwd"  lay-verify="required|password" placeholder="请输入原有密码" autocomplete="off" class="layui-input">
                        </div>
                    </div>
                    <div class="layui-form-item">
                        <label class="layui-form-label">新密码：</label>
                        <div class="layui-input-block">
                            <input type="password" name="newPwd" id="newPwd" lay-verify="required|password" placeholder="请输入新密码" autocomplete="off" class="layui-input">
                        </div>
                    </div>
                    <div class="layui-form-item">
                        <label class="layui-form-label">确认密码：</label>
                        <div class="layui-input-block">
                            <input type="password" name="newPwd2"  lay-verify="required" placeholder="请输入确认密码" autocomplete="off" class="layui-input">
                        </div>
                    </div>

                    <div class="layui-form-item">
                        <div class="layui-input-block">
                            <button class="layui-btn" lay-submit lay-filter="formSubmit2">保存</button>
                        </div>
                    </div>
                </form>

            </div>
        </div>
    </div>
</div>





<script src="/static/plugins/jquery.js"></script>
<script src="/static/plugins/layui/layui.js"></script>


<script>
    layui.use(['element','layer','form'],function () {
        var form = layui.form
        var layer = layui.layer

        form.on('submit(formSubmit1)',function (data){
            var serialize = $("#updateMsgForm").serialize();
            $.ajax({
                url:"/accountmsg/updateMsg",
                type:"post",
                dataType:"json",
                data:serialize,
                success:function (msg) {
                    layer.msg(msg.message,{icon:1,time:1000})
                },
                error:function () {
                    layer.msg("服务器异常")
                }
            })
            return false

        })


        form.on('submit(formSubmit2)',function (data){
            var serialize = $("#rsePwdForm").serialize();
            $.ajax({
                url:"/accountmsg/resetPwd",
                type:"post",
                dataType:"json",
                data:serialize,
                success:function (msg) {
                    if( msg.code == 1){
                        layer.msg("密码修改成功,请重新登录",{icon:1})
                        setTimeout(function () {
                            parent.location.href = "/logout"
                        },1500)
                    }else{
                        layer.msg(msg.message,{icon:2,time:1000})
                    }
                },
                error:function () {
                    layer.msg("服务器异常")
                }
            })
            return false

        })



        form.verify({
            password: [
                /^[\S]{6,12}$/
                ,'密码必须6到12位，且不能出现空格'
            ]
        })
    })



</script>
</body>
</html>
